package com.duniptech.engine.core.modeling;

import com.duniptech.engine.core.modeling.api.IAtomic;
import com.duniptech.engine.core.modeling.api.ICoupling;


/**
 * <P>Class for connections among the components of this coupled model.</P>
 * <P>A connection of a DEVS coupled model is defined by four identifiers. These are:
 * <UL>
 * <LI>The name of the component from where the connection comes.</LI>
 * <LI>The name of the port from where the connectio comes.</LI>
 * <LI>The name of the component to where the connection goes.</LI>
 * <LI>The name of the port to where the connection goes.</LI>
 * </UL>
 * </P>
 * 
 * @author Jos� Luis Risco Mart�n.
 */
public class Coupling implements ICoupling {
	private static final long serialVersionUID = 1L;
	/** Component at the origin of the connection. */
	private IAtomic componentFrom;
	/** Name of the port at the origin of the connection. */
	private String namePortFrom;
	/** Component at the destination of the connection. */
	private IAtomic componentTo;
	/** Name of the port at the destination of the connection. */
	private String namePortTo;
	/**
	 * Constructor
	 * @param componentFrom Component at the origin of the connection.
	 * @param namePortFrom Name of the port at the origin of the connection.
	 * @param componentTo Component at the destination of the connection.
	 * @param namePortTo Name of the port at the destination of the connection.
	 */
	public Coupling(IAtomic componentFrom, String namePortFrom, IAtomic componentTo, String namePortTo) {
		this.componentFrom = componentFrom;
		this.namePortFrom  = namePortFrom;
		this.componentTo   = componentTo;
		this.namePortTo    = namePortTo;
	}
	public IAtomic getComponentFrom() { return componentFrom; }
	public String getNamePortFrom() { return namePortFrom; }
	public IAtomic getComponentTo() { return componentTo; }
	public String getNamePortTo() { return namePortTo; }
	public void setComponentFrom(IAtomic component) { this.componentFrom = component; }
	public void setNamePortFrom(String namePortFrom) { this.namePortFrom = namePortFrom; }
	public void setComponentTo(IAtomic component) { this.componentTo = component; }
	public void setNamePortTo(String namePortTo) { this.namePortTo = namePortTo; }
	
	public String toString(){
		return "coupling: <"+
			componentFrom.getName()+":"+namePortFrom+"~~"+
			componentTo.getName()+":"+namePortTo+
			">\n";
	}
}
